package com.distributed.loginserver;

import java.util.List;
import java.util.Map;

import com.distributed.common.Address;
import com.distributed.common.Constant;
import com.distributed.util.ConfigLoader;

public class LoginConfiguration {
	private static Map<String, Object> config = null;

	public static void load() {
		config = ConfigLoader.load(Constant.LGN_CONFIG_FILE);
	}

	@SuppressWarnings("unchecked")
	public static List<Address> getDataServerList() {
		Object obj = config.get(Constant.LGN_DATA_SERVER_LIST);
		if (obj instanceof List<?>) {
			return (List<Address>) obj;
		} else {
			return null;
		}
	}

	@SuppressWarnings("unchecked")
	public static List<Address> getCacheServerList() {
		Object obj = config.get(Constant.LGN_CACHE_SERVER_LIST);
		if (obj instanceof List<?>) {
			return (List<Address>) obj;
		} else {
			return null;
		}
	}
	
	@SuppressWarnings("unchecked")
	public static List<Address> getLogicServerList() {
		Object obj = config.get(Constant.LGN_LOGIC_SERVER_LIST);
		if (obj instanceof List<?>) {
			return (List<Address>) obj;
		} else {
			return null;
		}
	}
	
	public static String getHostIp() {
		return (String) config.get(Constant.LOGIN_IP);
	}

	public static int getHostPort() {
		return (Integer) config.get(Constant.LOGIN_PORT);
	}
}
